/**
* @author Ashish Gupta
* CVSSP, University of Surrey
* Copyright (c) 2010 Ashish Gupta
* All rights reserved.
*/
/**
 * 
 */
package genetic;

import java.util.Random;

import configuration.GenePoolConfiguration;

/**
 * @author Ashish
 *
 */
public class RandomBlockMutation extends BlockMutation {

	/**
	 * 
	 */
	public RandomBlockMutation() {
	}

	/* (non-Javadoc)
	 * @see genetic.BlockMutation#operate(genetic.GeneMap)
	 */
	@Override
	public Object operate(GeneMap map, GenePoolConfiguration genePoolConfig) {
		int numKeysToMutate = (int) (map.keys().size() * genePoolConfig.getProportionKeysToMutateInBlockMutation()); 
		Random rnd = new Random();
		for(int i = 0; i < numKeysToMutate; i++){
			int keyIdx = rnd.nextInt(map.keys().size()); // the key to be mutated
			int valueIdx = rnd.nextInt(map.values().size()); // the key whose value will be put in mutated key
			Integer newValue = map.get(valueIdx); // the value to be placed in the mutated key
			map.put(keyIdx, newValue);
		}
		return map;
	}

	/* (non-Javadoc)
	 * @see genetic.GeneticOperator#operate(genetic.GeneMap, genetic.GeneMap, configuration.GenePoolConfiguration)
	 */
	@Override
	public Object operate(GeneMap mapFather, GeneMap mapMother,
			GenePoolConfiguration genePoolConfig) {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
